class Solution:
    def numTeams(self, rating: List[int]) -> int:
        total=0
        for i in range(len(rating)):
            ls=0
            lb=0
            rs=0
            rb=0
            for j in range(len(rating)):
                if j<i and rating[j]<rating[i]:
                    ls+=1
                if j<i and rating[j]>rating[i]:
                    lb+=1
                if j>i and rating[j]>rating[i]:
                    rb+=1
                if j>i and rating[j]<rating[i]:
                    rs+=1
            total+=ls*rb
            total+=lb*rs
        return total

'''
执行用时：
108 ms
, 在所有 Python3 提交中击败了
59.30%
的用户
内存消耗：
14.6 MB
, 在所有 Python3 提交中击败了
6.06%
的用户
'''